var switchItem = document.getElementsByClassName("switchItem");
var tabPage = document.getElementsByClassName("tabPage");

// 返回数组下标函数
function getArrayIndex(arr, obj) {
    var i = arr.length;
    while (i--) {
        if (arr[i] === obj) {
            return i;
        }
    }
    return -1;
}
// tab切换函数
function tabClick(tabOption,tabPage) {
	for (var index = 0; index < tabOption.length; index++) {
		tabOption[index].onclick = function() {
			if(getArrayIndex(tabOption, this) == 1){			
				// crateDepartment.style.display="none";
				// departmentManage.style.display="block";
			}
			if(getArrayIndex(tabOption, this) == 2){			
				// appendEmployee.style.display="none";
				// employeeManage.style.display="block";
			}
			if (this.classList.toString().search(/actived/) == -1) {
				for (var j = 0; j < tabOption.length; j++) {
					if (tabOption[j].classList.toString().search(/actived/) != -1) {
						tabOption[j].classList.remove("actived");
					}
				}
				this.classList.add("actived");
				for (var j = 0; j < tabPage.length; j++) {
					if (tabPage[j].classList.toString().search(/actived/) != -1) {
						tabPage[j].classList.remove("actived");
					}
				}
				tabPage[getArrayIndex(tabOption, this)].classList.add("actived");			
			}
		}
	}
}

tabClick(switchItem,tabPage);
